const { jwtSecret } = require("../config/config.default")
const jwt=require('../util/jwt')
exports.login=async(req,res,next)=>{
    try {
        //处理请求发送响应
    const user=req.user.toJSON()
    // delete user.password
    const token=await jwt.sign({
      userID:user._id
    },jwtSecret,{ expiresIn: 30 })
    delete user.password
        res.send({
         ...user,
          token
        })
    } catch (error) {
         next(error)
    }
}